package librarian;

import java.util.ArrayList;
import java.util.Iterator;

public class Library {
      static ArrayList<Book> books=new ArrayList<Book>( );
    
      public void findBook(String bookName){    	 
    	  Iterator it =books.iterator();
    	  while( it.hasNext( ) ) {
    		  Book b=((Book)it.next());
    		  boolean flag=b.getName().equals(bookName);
    		  if(flag){
    				System.out.println("\t" +b.toString());
    			}   	 
    	  } 
      }
      public ArrayList<Book> getAllBook(){    
    	  return books;   	  
      }
  	public Book findBookByAuthorName(String bookName,String authorName) {
		Iterator it = books.iterator();
		while (it.hasNext()) {
			  Book b=((Book)it.next());
    		  boolean flag=b.getAuthor().equals(authorName)&&b.getName().equals(bookName);
    		  if(flag){
    		       return b;
    			}   	  
		}
		return null;
	}
}
